/*******************************************************************************
* file  : base64 demo
* creat : apleilx
* data  : 2017/03/02
* @brief  	将一组二进制数编码为ASCII文本，解码可还原
*			堆栈无要求
*******************************************************************************/
#include "common.h"
#include "crc_ext.h"
#include "mbedtls/base64.h"


/*******************************************************************************
* @brief  des_demo.
* \param[in] none
* \retval: none
*******************************************************************************/
void base64_demo(void)
{
	void *src, *enc, *dec;
	size_t len_back;
	
	src = malloc(80);
	enc = malloc(80);
	dec = malloc(80);
	
	dbg_put_line();
	dbg_print("\nbase64 encode test \n");
	
	memcpy(src, led_code, 16);
	//set_u8(src, 0x33, 16);
	dbg_u8_print("src: ", src, 16, 20);
	
	mbedtls_base64_encode(enc, 80, &len_back, src, 16);
	dbg_print("enc: %s\n", enc);
	
	mbedtls_base64_decode(dec, 80, &len_back, enc, len_back);
	dbg_u8_print("dec: ", dec, len_back, 16);
	
	free(src);
	free(enc);
	free(dec);
}

